/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.web30.atom;




/**
 *
 * @author xiazy
 */
import org.apache.abdera.Abdera;
import org.apache.abdera.factory.Factory;
import org.apache.james.mime4j.message.Message;
import org.apache.abdera.model.Entry;
public class EntryBuilder {
    public static final String WEB30_URL = "www.web30core.org";
    public static Entry mime2Entry(Message msg) {
        if(msg == null)
            return null;
        
        Abdera abdera = new Abdera();
        Factory factory = abdera.getFactory();
        Entry entry = factory.newEntry();
        entry.setId("tag:"+ WEB30_URL +":/"+msg.getMessageId());
        entry.setTitle(msg.getSubject());
        entry.setContentAsHtml(msg.getBody().toString());
        entry.setPublished(msg.getDate());


        return entry;
    }
}
